package org.lisen.patterndemo.proxy;

/**
 * 代理模式的例子
 * @version 1.0
 * @project: patterndemo
 * @Description:
 * @Author: lisensir
 * @date: 2023/3/22 14:42:10
 */
public class JDKProxyDemo {
    public static void main(String[] args) {

        //设置系统属性，JDK将生成的代理类的字节码保存到磁盘上
        //也可以使用启动参数，-Dsun.misc.ProxyGenerator.saveGeneratedFiles=true
        System.setProperty("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");

        ISubject subject = new SubjectImpl();
        JDKProxy subjectProxy = new JDKProxy(subject);

        ISubject proxyInstance = (ISubject)subjectProxy.newProxy();

        proxyInstance.hello("world");
    }
}
